package com.xyongfeng.foodManagement.domain;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.xyongfeng.foodManagement.domain.group.AddGroup;
import com.xyongfeng.foodManagement.domain.group.NormalGroup;
import lombok.Data;
import org.hibernate.validator.constraints.Length;

import javax.validation.constraints.NotBlank;
import java.io.Serializable;

/**
 * @TableName food_category_info
 */
@TableName(value = "t_food_category_info")
@Data
public class FoodCategoryInfo implements Serializable {
    /**
     * 类别号
     */
    @TableId(type = IdType.AUTO)
    private Integer categoryId;

    /**
     * 类别名称
     */
    @Length(min = 1, max = 20, message = "类别名称长度范围为1~20",groups = {NormalGroup.class})
    @NotBlank(message = "类别名称不能为空", groups = {AddGroup.class})
    private String categoryName;

    /**
     * 是否易变质
     */
    private Boolean categoryEasyBad;

    @TableField(exist = false)
    private static final long serialVersionUID = 1L;

    @Override
    public boolean equals(Object that) {
        if (this == that) {
            return true;
        }
        if (that == null) {
            return false;
        }
        if (getClass() != that.getClass()) {
            return false;
        }
        FoodCategoryInfo other = (FoodCategoryInfo) that;
        return (this.getCategoryId() == null ? other.getCategoryId() == null : this.getCategoryId().equals(other.getCategoryId()))
                && (this.getCategoryName() == null ? other.getCategoryName() == null : this.getCategoryName().equals(other.getCategoryName()))
                && (this.getCategoryEasyBad() == null ? other.getCategoryEasyBad() == null : this.getCategoryEasyBad().equals(other.getCategoryEasyBad()));
    }

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + ((getCategoryId() == null) ? 0 : getCategoryId().hashCode());
        result = prime * result + ((getCategoryName() == null) ? 0 : getCategoryName().hashCode());
        result = prime * result + ((getCategoryEasyBad() == null) ? 0 : getCategoryEasyBad().hashCode());
        return result;
    }

    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append(getClass().getSimpleName());
        sb.append(" [");
        sb.append("Hash = ").append(hashCode());
        sb.append(", categoryId=").append(categoryId);
        sb.append(", categoryName=").append(categoryName);
        sb.append(", categoryEasyBad=").append(categoryEasyBad);
        sb.append(", serialVersionUID=").append(serialVersionUID);
        sb.append("]");
        return sb.toString();
    }
}